package com.example.undertow;

import io.undertow.Undertow;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;

import java.io.OutputStream;

public class UndertowConfig {


    public static void main(String[] args) {
        Undertow undertow = Undertow.builder()
                .addHttpListener(8087,"127.0.0.1", new MyHttpHandler())
                .build();
        undertow.start();
    }


    public static class MyHttpHandler implements HttpHandler {
        @Override
        public void handleRequest(HttpServerExchange httpServerExchange) throws Exception {
            System.out.println("啦啦啦啦");
//            OutputStream outputStream = httpServerExchange.getOutputStream();
//            String ss = "{'a':1,'b':2}";
//            for (int i=0;i<ss.getBytes().length;i++){
//                outputStream.write(ss.getBytes()[i]);
//            }
//            outputStream.flush();
        }
    }

}
